CSharpTest.Net
SendTo(Int32,IEnumerable<String>,String,String[]) Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class > SendTo Method : SendTo(Int32,IEnumerable<String>,String,String[]) Method

waitTime
instances
eventName
arguments

Glossary Item Box

Sends the event to the specified list of instance identities or names (case-insensitive)

Syntax

Visual Basic (Declaration) 
Public Overloads Function SendTo( _
   ByVal waitTime As Integer, _
   ByVal instances As IEnumerable(Of String), _
   ByVal eventName As String, _
   ByVal ParamArray arguments() As String _
) As Integer
C# 
public int SendTo( 
   int waitTime,
   IEnumerable<string> instances,
   string eventName,
   params string[] arguments
)

Parameters

waitTime
instances
eventName
arguments

Example

Library/Library.Test/TestIpcChannel.cs

C#Copy Code
using (IpcEventChannel sender = new IpcEventChannel(_registrar, _channel))
using (IpcEventChannel ch1 = new IpcEventChannel(_registrar, _channel))
using (IpcEventChannel ch2 = new IpcEventChannel(_registrar, _channel))
{
    ch1.StartListening("ch1");
    ch2.StartListening("ch2");

    int ch1Count = 0, ch2Count = 0;
    ch1["Message"].OnEvent += delegate(object o, IpcSignalEventArgs e) { ch1Count++; };
    ch2["Message"].OnEvent += delegate(object o, IpcSignalEventArgs e) { ch2Count++; };

    sender.ExecutionTimeout = 1000;
    Assert.AreEqual(1, sender.SendTo("CH1", "Message"));
    Assert.AreEqual(1, sender.SendTo(new string[] { "CH2" }, "Message"));
    Assert.AreEqual(2, sender.SendTo(1000, new string[] { "ch1", "ch2" }, "Message"));

    ch1.StopListening();
    Assert.AreEqual(2, ch1Count);
    ch2.StopListening();
    Assert.AreEqual(2, ch2Count);
}
VB.NETCopy Code
Using sender As New IpcEventChannel(_registrar, _channel)
    Using ch1 As New IpcEventChannel(_registrar, _channel)
        Using ch2 As New IpcEventChannel(_registrar, _channel)
            ch1.StartListening("ch1")
            ch2.StartListening("ch2")

            Dim ch1Count As Integer = 0, ch2Count As Integer = 0
            ch1("Message").OnEvent += Function(o As Object, e As IpcSignalEventArgs) Do
                System.Math.Max(System.Threading.Interlocked.Increment(ch1Count),ch1Count - 1)
            End Function
            ch2("Message").OnEvent += Function(o As Object, e As IpcSignalEventArgs) Do
                System.Math.Max(System.Threading.Interlocked.Increment(ch2Count),ch2Count - 1)
            End Function

            sender.ExecutionTimeout = 1000
            Assert.AreEqual(1, sender.SendTo("CH1", "Message"))
            Assert.AreEqual(1, sender.SendTo(New String() {"CH2"}, "Message"))
            Assert.AreEqual(2, sender.SendTo(1000, New String() {"ch1", "ch2"}, "Message"))

            ch1.StopListening()
            Assert.AreEqual(2, ch1Count)
            ch2.StopListening()
            Assert.AreEqual(2, ch2Count)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys